﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using BikeSystem.Models;
using BikeSystem.BLL;

namespace BikeUI
{
    public partial class FormRental : Form
    {
        protected RentalManager rentalManager = new RentalManager();
        public FormRental()
        {
            InitializeComponent();

        }

        public bool Editable
        {
            get { return true; }
            set { 
                gbxRental.Enabled = value;
                btnSave.Visible = value;
            }
        }

        public GroupBox GroupBoxRental
        {
            get { return gbxRental; }
            set { gbxRental = value;}
        }


        public BindingSource BindingSource
        {
            get { return rentalBindingSource; }
            set { rentalBindingSource = value; }
        }

        protected virtual void btnSave_Click(object sender, EventArgs e)
        {

            Rental rental = (Rental)rentalBindingSource.Current;

            CommonMessage msg = rentalManager.Rental(rental);
            MessageBox.Show(msg.Message, msg.Caption);
            if(msg.Success){
                this.Close();
            }

        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
